<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书类型页面</title>
<link rel="stylesheet" type="text/css"
	href="../jquery/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../jquery/themes/icon.css">
<script type="text/javascript" src="../jquery/jquery.min.js"></script>
<script type="text/javascript" src="../jquery/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../jquery/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		
		$("#btn-buy-book").click(function(){
			 $.post('../buyBook',function(data){
				 $.messager.alert('消息','实际付款为:'+data+'  元','info');
			 })
			
		})

		$("#btn-add").click(function() {
			$("#add-dialog").dialog({
				closed : false,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-save',
					handler : function() {
						$('#add-form').form('submit', {
							url : '../saveOrderInfo',
							onSubmit : function() {
								return $('#add-form').form('validate');
							},
							success : function(flag) {
								if (flag) {
									alert('下单成功');
									$("#add-dialog").dialog({
										closed : true
									});
									$('#add-form').form('clear');
									$("#dg").datagrid('load');

								} else {
									alert('下单失败');
								}

							}
						});

					}
				}, {
					text : '重置',
					iconCls : 'icon-redo',
					handler : function() {
						$("#add-form").form('clear');

					}
				}, {
					text : '关闭',
					iconCls : 'icon-cancel',
					handler : function() {
						$("#add-form").form('clear');
						$("#add-dialog").dialog({
							closed : true
						})
					}
				} ]
			})

		})
		$("#btn-search").click(function() {
			$('#dg').datagrid('load', {
				bName : $("#bName").val(),
			})
		})

		$('#dg').datagrid({
			url : '../findOrderWithPage',
			fit : true,
			fitColumns : true,
			pagination : true,
			nowrap : false,
			toolbar : '#tb',
			pagePosition : 'both',
			columns : [ [ {
				field : 'oId',
				title : '下单ID',
				width : 100,
				checkbox : true
			}, {
				field : 'bName',
				title : '图书名称',
				width : 100
			}, {
				field : 'quantity',
				title : '购买数量',
				width : 100
			}, {
				field : 'orderTime',
				title : '下单时间',
				width : 100
			}, {
				field : 'buyTime',
				title : '购买时间',
				width : 100
			}, {
				field : 'price',
				title : '图书单价(单位/元)',
				width : 100
			}, {
				field : 'sumPrice',
				title : '总价(单位/元)',
				width : 100
			}, {
				field : 'uName',
				title : '客户名称',
				width : 100
			}

			] ]
		});

	})
</script>
</head>
<body>
	<div id="tb">
		<table>
			<tr>
				<td>图书名称</td>
				<td><input id="publish" class="easyui-validatebox" /><a
					id="btn-search" href="#" class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-search'">查询</a></td>

			</tr>


		</table>
		<a id="btn-add" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-add'">下单信息添加</a> <a
			id="btn-edit" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-edit'">下单信息修改</a> <a
			id="btn-remove" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-remove'">下单信息删除</a> <a
			id="btn-buy-book" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-man'">付款</a>
	</div>



	<div id="dg"></div>

	<div id="add-dialog" class="easyui-dialog" title="添加图书信息"
		style="width: auto; height: auto;"
		data-options="modal:true,closed:true,closable:false">
		<form id="add-form" method="post">
			<table>
				<tr>
					<td>图书名称</td>
					<td><select id="cc" class="easyui-combogrid" name="bId"
						style="width: 150px;"
						data-options="required:true,  
            panelWidth:450,   
            idField:'bId',   
            textField:'bName',   
            url:'../findBookWithPage',
            fitColumns:true,
            fit:true,
            pagination:true,   
            columns:[[   
                {field:'bId',title:'图书ID',width:100,checkbox:true},   
                {field:'bName',title:'图书名称',width:100},   
                {field:'quantity',title:'库存数量',width:100},   
                {field:'author',title:'作者',width:100}   
            ]]   
        "></select>
					</td>


				</tr>
				<tr>
					<td>购买数量</td>
					<td><input name="quantity" class="easyui-numberspinner"
						style="width: 150px;"
						data-options="required:true,min:1,editable:false"></td>
				</tr>


			</table>
		</form>

	</div>

</body>
</html>